<?php

/**
 * Menashop
 *
 * LICENSE
 *
 * This source file is subject to the license that is bundled
 * with this project in the file LICENSE.txt
 *
 * @category   Zend
 * @package    Storefront_View_Helper
 * @subpackage ProductPagination
 * @copyright  Copyright (c) 2011 Menashop UA Inc. (http://www.menashop.com.ua)
 * @license    LICENSE.txt
 * @version    1.0.0
 * @since      File available since Release 1.0.0
 */

/**
 * The helper for product pagination
 * 
 * @category   Zend
 * @package    Storefront_View_Helper
 * @subpackage ProductPagination
 * @copyright  Copyright (c) 2011 Menashop UA Inc. (http://www.menashop.com.ua)
 * @license    LICENSE.txt
 */
class Storefront_View_Helper_ProductPagination extends Zend_View_Helper_Abstract
{

    /**
     * Get HTML for the product paginator
     */
    public function productPagination()
    {
        $output = "";
        $page = $this->view->page;
        $pageCount = $this->view->pageCount;
        $url = $this->view->paginationUrl;
        $rowCount = $this->view->rowCount;
        if ($pageCount) {
            $output .= '<div class=pagination>';
            // First page link
            if ($page != 1) {
                $output .= '<a href="' . $url . '&page=1&rows=' . $rowCount . '">1&lt;&lt;</a>  ';
            } else {
                $output .= '<span>1&lt;&lt; </span> ';
            }

            // Previous page link
            if ($page != 1) {
                $output .= '<a href="' . $url . '&page=' . ($page - 1) . '&rows=' . $rowCount . '">&lt;</a>  ';
            } else {
                $output .= '<span> &lt;</span>  ';
            }

            // Current page link
            $output .= '<a href="' . $url . '&page=' . $page . '&rows=' . $rowCount . '">' . $page . '</a>  ';

            // Next page link
            if ($page < $pageCount) {
                $output .= '<a href="' . $url . '&page=' . ($page + 1) . '&rows=' . $rowCount . '">&gt;</a> ';
            } else {
                $output .= '<span>&gt;</span> ';
            }

            // Last page link
            if ($page < $pageCount) {
                $output .= '<a href="' . $url . '&page=' . $pageCount . '&rows=' . $rowCount . '"> &gt;&gt;' . $pageCount . '</a>';
            } else {
                $output .= '<span> &gt;&gt;' . $pageCount . '</span>';
            }
            $output .= '</div>';
        }
        return $output;
    }

}
